<% 
revisions = Roroacms::Post.where(:ancestry => @post.ancestry, :post_type => 'autosave').order('created_at desc')
if revisions.length > 0 %>
  <table class="table table-hover">
    <thead>

      <th><%= t("views.admin.partials.revisions.autosave_table.date") %></th>
      <th><%= t("views.admin.generic.author") %></th>
      <th>&nbsp;</th>

    </thead>
    <% revisions.each do |d| %>

      <tr <%= d.id == @revision['revision'].id ? 'class=active' : '' %>>
        <td><%= t("views.admin.partials.revisions.autosave_table.revision_saved_at") %> <%= d.created_at.strftime("%d %B, %Y at %H:%M") %></td>
        <td><%= (d.post_status.downcase == 'user-autosave' || d.post_type.downcase == 'page') ? d.admin.username : t("views.admin.generic.system") %></td>
        <td>
          <div class="btn-group pull-right">
            <%= link_to restore_admin_revision_path(d), :class => 'btn btn-default btn-xs' do %>
              <i class="fa fa-magic"></i>
            <% end %>        
            <%= link_to edit_admin_revision_path(d), :class => 'btn btn-default btn-xs' do %>
              <i class="fa fa-search"></i>
            <% end %>
          </div>
        </td>
      </tr>

    <% end %>

  </table>

<% else %>

  <p><%= t("views.admin.partials.revisions.autosave_table.only_revision") %></p>

<% end %>